home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************
- "text.c"
-
- by John A. Love, III [Washington Apple Pi Users' Group]
-
- using Symantec's "THINK C", v 5.00
- *********************************************************/
-
-
- #include <Traps.h>
-
- #include "protos"
-
- #include "globals.h"
- #include "extern.h"
-
-
-
-
- Boolean StylizedTE (void) {
-
-
- return ( TrapAvailable(_TEStyleNew) );
-
- } /* StylizedTE */
-
-
-
- short GetLineHeight (Boolean styleTE, TEHandle teH, short theLine) {
-
-
- if (styleTE) {
- if (theLine == 0) theLine = 1;
- return ( TEGetHeight(theLine, theLine, teH) );
- }
- else return ( (*teH)->lineHeight );
-
- } /* GetLineHeight */
-
-
-
- short GetLineNbr (Boolean styleTE, TEHandle teH, short pix) {
- /* Used old technique of halfing line count, instead of
- adding each-and-every line's height. Saved BIG time. */
-
- short nbrLines, halfWay, currentLine;
- short linesHt = 0; /* ... in case nbrLines = 1
- ** AND
- ** pix < one line's worth,
- ** which could easily happen
- ** using the Scroll Bar's Thumb */
- nbrLines = (**teH).nLines;
- if (nbrLines == 0) return (0);
- if (pix == 0) return (1);
-
- if (styleTE) {
- halfWay = nbrLines;
- /* Expansion of while-loop below:
- for (;;) {
- halfWay = halfWay >> 1;
- if (halfWay < 1) break;
- linesHt = TEGetHeight(halfWay, 1, teH);
- if (linesHt <= pix) break;
- }
- */
- while ( ((halfWay >>= 1) >= 1) &&
- ((linesHt = TEGetHeight(halfWay, 1, teH)) > pix) );
-
- // Begin where we left off (linesHt from 1 to halfWay):
- for (currentLine = halfWay+1; currentLine <= nbrLines; currentLine++) {
- linesHt += TEGetHeight(currentLine, currentLine, teH);
- if (linesHt > pix) break;
- }
- --currentLine; // 1 more than real line # coming out of for-loop.
-
- } /* new stylized text */
-
- else /* old stuff */ currentLine = pix / (**teH).lineHeight;
-
- return (currentLine);
-
- } /* GetLineNbr */
-
-
-
-
- /* { end file "text.c" } */
-